package stream;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class operator_union {
    public static void main(String[] args) throws Exception {
    //   创建流式数据环
        StreamExecutionEnvironment env =  StreamExecutionEnvironment.getExecutionEnvironment();
    //    添加数据源
        DataStreamSource<Long> source1 = env.addSource(new oneparalleSource());
        DataStreamSource<Long> source2 = env.addSource(new oneparalleSource());

        DataStream<Long> result = source1.union(source2);

        result.map(new MapFunction<Long, Long>() {
            public Long map(Long aLong) throws Exception {
                System.out.println("shuju:" + aLong);
                return null;
            }
        });

        result.print().setParallelism(2);
        env.execute("operator_union");
    }
}

